import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class TestDay29 {

    //找假币
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            int n = scanner.nextInt();
            if(n == 0){
                return;
            }

            System.out.println(func(n));
            // 7 7 0 14
            // 9 9 1 19
            // 4 4 1 9

        }
    }

    public static int func(int a){
        if(a == 1){
            return 0;
        }
        if(a <= 3){
            return 1;
        }
        int m = a/3 + (a%3 == 0?0:1);
        int n = a-2*m;
        //6  2 2 2   2 2 2
        //7  2 2 3  3 3 1
        //8  2 2 4  3 3 2
        //9  3 3 3
        //14 4 4 6  5 5 4
        //17 5 5 7  6 6 5
        int tmp = 1+func(Math.max(m,n));
        return tmp;
    }

    public static void main(String[] args) {
        int[]array = {8,10,2,10,4,8,6,3,5,7,10};
        System.out.println(getFirstUnFormedNum(array));
    }
    //最小不可组成和
    public static int getFirstUnFormedNum(int[] arr) {
//
        int min = Integer.MAX_VALUE;
        int max = 0;
        for (int j : arr) {
            if (min > j) {
                min = j;
            }
            max += j;
        }
        HashSet<Integer> hashSet = new HashSet<>();

        //将这个数组内的所有可能出现的和都放入hashmap
        for (int i = 0; i < arr.length; i++) {
            hashSet.add(arr[i]);
            //他不一定是两个数的和,可能是更多数的和

          }

        for (int i = min+1; i <max ; i++) {
            //看看是否包含i,如果不包含则打印
            if(!hashSet.contains(i)){
                return i;
            }
        }
        return max+1;

    }
}
